package it.unibo.refolding.pico;

public abstract class AbstractNanoDriver implements NanoDriver {

  private final double startOrPauseStripChartPixelIsRedTimeS;
  
  public AbstractNanoDriver(double startOrPauseStripChartPixelIsRedTimeS) {
    this.startOrPauseStripChartPixelIsRedTimeS = startOrPauseStripChartPixelIsRedTimeS;
  }

  @Override
  public void captureButtonResetStripChart() {
    captureButton();
    resetStripChart();
  }

  @Override
  public void startStripChartQuitStripChartForceMode() {
    startStripChart();
    quitStripChart();
    forceMode();
  }

  @Override
  public void zScanStartMScriptModeStartStripChart(double zScanStartM) {
    zScanStartM(zScanStartM);
    scriptMode();
    startStripChart();
  }

  @Override
  public void forceModeXOffsetScriptMode(double xOffsetM) {
    forceMode();
    xOffsetM(xOffsetM);
  }
  
  @Override
  public void waitWhileStartOrPauseIsNotRed() {
    while (!startOrPauseStripChartPixelIsRed()) {
      sleep(startOrPauseStripChartPixelIsRedTimeS);
    }
  }
}
